<template>
	<view class="modular">
		<view class="headerBox">
			<view class="header">
				<view class="information">
					<view>
						<view><text>会员</text>：{{data.userName}} </view>
						<view><text>填写日期</text>：{{data.fillFormDate}}</view>
					</view>
					<view>
						<view><text>性别</text>：{{userInfo.sex && userInfo.sex == 1 ? '男' : '女' || ''}} </view>
						<view><text>年龄</text>：{{userInfo && userInfo.age}}</view>
					</view>
					<view>
						<view><text>评估人</text>：{{data.userHealthName}}</view>
						<view><text>评估日期</text>：{{data.lastUpdateTime ? data.lastUpdateTime && data.lastUpdateTime.split(' ')[0] : data.createdDate && data.createdDate.split(' ')[0]}}</view>
					</view>
				</view>
			</view>
			
			<view class="connectBox" v-show="!searchBarFixed">
				<image src="@/static/img/healthStatus/connect@2x.png"></image>
				<image src="@/static/img/healthStatus/connect@2x.png"></image>
			</view>
		</view>
		<view class="mainContent">
			<view class="specific">
				<image src="@/static/img/futureDiseases/diabetesDetails@2x.png" class="title"></image>
				<view class="single" v-for="(item,index) in psychologyQuestion" :key="index">
					<image src="@/static/img/healthStatus/questionIcon@2x.png"></image>
					<view>
						<view class="question">{{item.name}}</view>
						<view class="answer">
							{{item.dataValue}}
						</view>
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {age,distance} from '@/static/js/filter.js'
	export default{
		data() {
			return {
				psychologyQuestion:[],
				data:{},
				answer: [],
				userInfo: {},
				searchBarFixed: false
			}
		},
		onLoad(option) {
			const _this = this;
			if(option.id) {
				_this.question().then((reponse) => {
					if(reponse) {
						_this.$api.appSicknessDangeDetail(option.id).then((res) => {
							if(res.data.returnCode == 200) {
								_this.data = res.data.result;
								_this.psychologyQuestion.map((a) => {
									res.data.result && res.data.result.userTopicsEntities.map((b,bi) => {
										if(a.id == b.titleId) {
											a.dataValue = b.userValue							
										}
									})
								})
										
								_this.$api.getUserInfo().then((res) => {
									if(res.data.returnCode == 200) {
										_this.userInfo = res.data && res.data.result
									}
								})
							}
						})
					}
					
				})
			}
			
		},
		onPageScroll() {
			this.searchBarFixed = this.distance('mainContent');
		},
		methods:{
			age,
			distance,
			question() {
				return new Promise((success,error)=>{
					this.$api.psychologyQuestion('ids=48').then((res)=>{
						if(res){
							this.psychologyQuestion = res.data.result[48] && res.data.result[48].adTopicsRepliesEntityList.map((a)=>{
								a.adTopicsRepliesEntityList = a.adTopicsRepliesEntityList.map((b)=>{b.checked = false;return b})
								return a
							})
							success(res.data.result)
						}else{
							error('')
						}
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/css/healthStatus/toView.scss';
</style>
